import request from '@/utils/request'
import type{ QueryParams, RuleForm } from "@/views/dish/category/types";
// 查询所有类别
export function listAllCategory() {
  return request({
    url: '/category/listAll',
    method: 'get'
  })
}

// 查询类别列表
export function listCategory(query: QueryParams) {
  return request({
    url: '/category',
    method: 'get',
    params: query
  })
}

// 分页查询类别列表
export function listCategoryByPage(query: QueryParams) {
  return request({
    url: '/category/page',
    method: 'get',
    params: query
  })
}

// 根据id查询类别
export function getCategoryById(categoryId: number) {
  return request({
    url: '/category/' + categoryId,
    method: 'get'
  })
}

// 根据categoryName查询类别
export function getCategoryByName(categoryName: string) {
  return request({
    url: '/category/' + categoryName,
    method: 'get'
  })
}

// 新增类别
export function addCategory(data: RuleForm) {
  return request({
    url: '/category',
    method: 'post',
    data: data
  })
}

// 修改类别
export function updateCategory(data: RuleForm) {
  return request({
    url: '/category',
    method: 'put',
    data: data
  })
}

// 删除类别
export function deleteCategory(categoryId: number) {
  return request({
    url: '/category/' + categoryId,
    method: 'delete'
  })
}

// 批量删除类别
export function deleteCategoryBatch(categoryIds: number[]) {
  return request({
    url: '/category/delBatch/' + categoryIds,
    method: 'delete'
  })
}
